package com.model.xmlElement.input;

import java.io.Serializable;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import constant.XmlElementCoonstant;

/**
 * *********************************************
 * @author Administrator
 * @FileName Target.java
 * @Description XML配置之目标配置
 **********************************************
 */
@XmlAccessorType(XmlAccessType.FIELD)
public class Target implements Serializable{
	public static final Logger LOG = LoggerFactory.getLogger(Target.class);
	private static final long serialVersionUID = 1L;
	
	@XmlElement(name = "target_name")
	private String name;												//抓取来源
	@XmlElement(name = "target_description")
	private String description;											//抓取来源说明
	@XmlElement(name = "target_baseurl")
	private String baseUrl;												//根节点URL
	@XmlElement(name = "target_level")
	private int level;													//抓取层级
	@XmlElement(name = "target_xpath")					
	private String xpath;												//第一层取值Document
	@XmlElement(name = "target_patten")
	private String patten;												//URL满足条件
	@XmlElement(name = "target_threads")
	private int threadsNumber;											//线程数量
	@XmlElement(name = "target_run_ip")
	private String targetRunIp;											//任务执行ip
	@XmlElement(name = "target_execute_time")
	private String targetExecuteTime;									//任务执行时间
	@XmlElement(name = "target_execute_cycle")
	private int targetExecuteCycle;										//任务执行周期
	@XmlElement(name = "target_save_seed1")
	private boolean target_save_seed1;									//抓取文档中是否保存URL
	@XmlElement(name = "target_save_seed2")
	private boolean target_save_seed2;									//所有URL是否单独保存
	
	private String taskId;												//taskId
	private String taskUser;											//taskUser
	private String taskTime;											//taskTime
	
	
	public boolean isTarget_save_seed1() {
		return target_save_seed1;
	}
	public void setTarget_save_seed1(boolean target_save_seed1) {
		this.target_save_seed1 = target_save_seed1;
	}
	public boolean isTarget_save_seed2() {
		return target_save_seed2;
	}
	public void setTarget_save_seed2(boolean target_save_seed2) {
		this.target_save_seed2 = target_save_seed2;
	}
	public String getXpath() {
		return xpath;
	}
	public void setXpath(String xpath) {
		this.xpath = xpath;
	}
	public String getTargetRunIp() {
		return targetRunIp;
	}
	public void setTargetRunIp(String targetRunIp) {
		this.targetRunIp = targetRunIp;
	}
	public int getTargetExecuteCycle() {
		return targetExecuteCycle;
	}
	public void setTargetExecuteCycle(int targetExecuteCycle) {
		this.targetExecuteCycle = targetExecuteCycle;
	}
	public void setThreadsNumber(int threadsNumber) {
		this.threadsNumber = threadsNumber;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getBaseUrl() {
		return baseUrl;
	}
	public void setBaseUrl(String baseUrl) {
		this.baseUrl = baseUrl;
	}
	public int getLevel() {
		return level;
	}
	public void setLevel(int level) {
		this.level = level;
	}
	public String getPatten() {
		return patten;
	}
	public void setPatten(String patten) {
		this.patten = patten;
	}
	public String getTargetExecuteTime() {
		return targetExecuteTime;
	}
	public void setTargetExecuteTime(String targetExecuteTime) {
		this.targetExecuteTime = targetExecuteTime;
	}
	
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getTaskId() {
		return taskId;
	}
	public void setTaskId(String taskId) {
		this.taskId = taskId;
	}
	public String getTaskTime() {
		return taskTime;
	}
	public void setTaskTime(String taskTime) {
		this.taskTime = taskTime;
	}
	public String getTaskUser() {
		return taskUser;
	}
	public void setTaskUser(String taskUser) {
		this.taskUser = taskUser;
	}
	
	public Target() {
		super();
	}
	public Target(String name,String description,String baseUrl, int level, String patten) {
		super();
		this.name = name;
		this.description = description;
		this.baseUrl = baseUrl;
		this.level = level;
		this.patten = patten;
	}
	/**
	 * 线程数量
	 * @return
	 */
	public int getThreadsNumber() {
		if(threadsNumber > XmlElementCoonstant.MAX_THREADS_NUMBER){
			return 100;
		}else{
			return threadsNumber;
		}
	}
	
	/**
	 * taskId和taskUser和taskTime
	 * @return
	 */
	public String getTaskUUIDAndUserAndTime(){
		return new StringBuilder(60).append(taskId).append("_").append(taskUser).append("_").append(taskTime).toString();
	}
	/**
	 * taskId和taskTime和name
	 * @return
	 */
	public String getTaskUUIDAndTimeAndName(){
		return new StringBuilder(60).append(taskId).append("_").append(taskTime).append("_").append(name).toString();
	}
}
